﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;

namespace BestCode.Creds.UI
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            // define application exception handler
            Application.Current.DispatcherUnhandledException += AppDispatcherUnhandledException;

            // defer other startup processing to base class
            base.OnStartup(e);
        }

        void AppDispatcherUnhandledException(object sender,
           DispatcherUnhandledExceptionEventArgs e)
        {
            //do whatever you need to do with the exception
            //e.Exception
            MessageBox.Show(e.Exception.Message);

            e.Handled = true;
        }
    }



   /* internal delegate void Invoker();
    public partial class App : Application
    {
        public App()
        {
            ApplicationInitialize = _applicationInitialize;
        }
        public static new App Current
        {
            get { return Application.Current as App; }
        }
        internal delegate void ApplicationInitializeDelegate(VwSplash splashWindow);
        internal ApplicationInitializeDelegate ApplicationInitialize;
        private void _applicationInitialize(VwSplash splashWindow)
        {
            // fake workload, but with progress updates.
            Thread.Sleep(500);
            splashWindow.SetProgress(0.2);

            Thread.Sleep(500);
            splashWindow.SetProgress(0.4);

            Thread.Sleep(500);
            splashWindow.SetProgress(0.6);

            Thread.Sleep(500);
            splashWindow.SetProgress(0.8);

            Thread.Sleep(500);
            splashWindow.SetProgress(1);

            // Create the main window, but on the UI thread.
            Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Invoker)delegate
            {
                MainWindow = new VwMain();
                ((VwMain) MainWindow).OnEntitiesLoaded += (o, i) => MainWindow.Show();
                //MainWindow.Show();
            });
        }

     
    }*/

}
